
<?php 
if (!empty($dataItemInfo)){
	$arrName = array();
	foreach ($dataItemInfo as $dataItemInfo){
		$arrName[$dataItemInfo['Area']['id']] = $dataItemInfo['Area']['name'];
	}
//	debug($arrName);
}?>
<div style = "width: 500px">	
	<div class="modal-header " align ="center" style = "color: green">
	    <h3>Label</h3>
 	 </div>
 	 <br>
	<?php echo $this->Form->create('Label', array('class' => "form-horizontal", 'id' => 'myform', 'url' => array('controller' => 'management', 'action' => 'add_items')));?>
	  <div align ="center">
	  	<table>
	  		<tr>
	  			<td>Area Name</td>
	  			<td><?php echo $this->Form->select('area_id', array(isset($arrName)?$arrName:null), array('class' => 'selectAreaName')); ?> </td>
	  			<td></td>
	  		</tr>
	  		<?php echo $this->Form->input('screen_id', array('label' => false, 'type' => 'hidden', 'value' => isset($idScreen)?$idScreen:null));?>
	  		<tr>
	  			<td>Item Name(Vi)</td>
	  			<td><?php echo $this->Form->input('item_name', array('label' => false));?></td>
	  			<td></td>
	  		</tr>
	  		<tr>
	  			<td>Dynamic Value</td>
	  			<td><?php echo $this->Form->checkbox('is_dynamic', array('label' => false));?></td>
	  			<td></td>
	  		</tr>
	  		<tr>
	  			<td>Value</td>
	  			<td><?php echo $this->Form->input('value', array('label' => false));?></td>
	  			<td><?php echo $this->Form->checkbox('unclearValue', array('label' => false ));?>Unclear</td>
	  		</tr>
	  		<tr>
	  			<td>Font</td>
	  			<td><?php echo $this->Form->input('font', array('label' => false ));?></td>
	  			<td><?php echo $this->Form->checkbox('unclearFont', array('label' => false ));?>Unclear</td>
	  		</tr>
	  		<tr>
	  			<td>Color</td>
	  			<td><?php echo $this->Form->input('color', array('label' => false ));?></td>
	  			<td><?php echo $this->Form->checkbox('unclearColor', array('label' => false ))."Unclear";?></td>
	  		</tr>
	  		<tr>
	  			<td>Length</td>
	  			<td><?php echo $this->Form->input('length', array('label' => false , 'style' => 'width: 50px' ));?></td>
	  			<td><?php echo $this->Form->checkbox('unclearLength', array('label' => false  ))."Unclear";?></td>
	  		</tr>
	  		<tr>
	  			
	  			<td>Permission</td>
	  			<td><?php echo $this->Form->select('permission', array(), array('class' => 'selectPermission' )); ?></td>
	  			<td><?php echo $this->Form->checkbox('unclearPermission', array('label' => false ,))."Unclear";?></td>
	  		</tr>
	  	</table>
	  </div>
	  <div class="modal-footer" >
	     <div align = "center">
	     <button type="submit" class="btn btn-primary">Save</button>
	     </div> 
	  </div>
	  
	<?php echo $this->Form->end();?>
	
</div>



<script type="text/javascript">
$( "#myform" ).validate({
	  rules: {
		"data[Label][area_id]": {
			 	required: true,
			 	min:1
		},
		"data[Label][item_name]": {
		 	required: true
		 },
		"data[Label][value]": {
			required: true
		},
		"data[Label][font]": {
			required: true
		},
		"data[Label][color]": {
			required: true
		},
		"data[Label][length]": {
			required: true,
            maxlength: 4,
            number: true,
            min: 1 
		},
	  }
	});
$(".selectAreaName").select2({
    placeholder: "Selection...",
    
});
$(".selectPermission").select2({
    placeholder: "Selection...",
    
});
</script>










